﻿using System.Linq.Expressions;

namespace EaseDapper
{
    public static class ExtendExpress
    {
        public static string TransferExpressionCustomMethod(this string type)
        {
            string operand = string.Empty;
            switch (type)
            {
                case "Like":
                    operand = " LIKE ";
                    break;
                case "Set":
                case "Equals":
                    operand = " = ";
                    break;
                case "Unequal":
                    operand = " <> ";
                    break;
                case "In":
                    operand = " In ";
                    break;
                case "With":
                    operand = " With ";
                    break;
            }
            return operand;
        }

        //操作符转换
        public static string TransferExpressionType(this ExpressionType type)
        {
            string operand = string.Empty;
            switch (type)
            {
                case ExpressionType.AndAlso:
                    operand = " AND ";
                    break;
                case ExpressionType.OrElse:
                    operand = " OR ";
                    break;
                case ExpressionType.Equal:
                    operand = " = ";
                    break;
                case ExpressionType.LessThan:
                    operand = " < ";
                    break;
                case ExpressionType.LessThanOrEqual:
                    operand = " <= ";
                    break;
                case ExpressionType.GreaterThan:
                    operand = " > ";
                    break;
                case ExpressionType.GreaterThanOrEqual:
                    operand = " > ";
                    break;
            }
            return operand;
        }
    }
}
